package com.fzq.config;

import com.fzq.service.MaskingStrategy;
import com.fzq.service.impl.NameMaskingStrategy;
import com.fzq.service.impl.PhoneMaskingStrategy;

import java.util.HashMap;
import java.util.Map;


public class MaskingStrategyFactory {
    private static final Map<Sensitive.SensitiveType, MaskingStrategy> STRATEGY_CACHE = new HashMap<>();

    static {
        STRATEGY_CACHE.put(Sensitive.SensitiveType.PHONE, new PhoneMaskingStrategy());
//        STRATEGY_CACHE.put(Sensitive.SensitiveType.ID_CARD, new IdCardMaskingStrategy());
//        STRATEGY_CACHE.put(Sensitive.SensitiveType.EMAIL, new EmailMaskingStrategy());
//        STRATEGY_CACHE.put(Sensitive.SensitiveType.BANK_CARD, new BankCardMaskingStrategy());
        STRATEGY_CACHE.put(Sensitive.SensitiveType.NAME, new NameMaskingStrategy());
//        STRATEGY_CACHE.put(Sensitive.SensitiveType.ADDRESS, new AddressMaskingStrategy());
//        STRATEGY_CACHE.put(Sensitive.SensitiveType.CUSTOM, new CustomMaskingStrategy());
    }

    public static MaskingStrategy  getStrategy(Sensitive.SensitiveType type) {
        return STRATEGY_CACHE.getOrDefault(type, (v, p) -> v);
    }
}
